/*
 * SubWindow.h
 *
 *  Created on: 2024年9月9日
 *      Author: nwz
 */

#ifndef CODE_SUBWINDOW_H_
#define CODE_SUBWINDOW_H_

class SubWindow: public wxFrame {
public:
	SubWindow(AttachWindow& attach);
	virtual ~SubWindow();

	void init(wxWindow *window, struct table_tab &tb, struct table_tab_win*);

	bool isClosed() {
		return closed;
	}

	struct table_tab_win* getWinData() {
		return &win_data;
	}

	void onClose(){
		wxCloseEvent event;
		onClose(event);
	}

private:
	void terminalProcess();
	enum {
		ID_UI_TEXT_FILE,
		ID_UI_FILE_BROWER,
		ID_UI_TEXT_ARG,
		ID_UI_CHECK_BOX_ATTACH_WINDOW,
		ID_UI_CHECK_BOX_FIND_WITH_NAME,
		ID_UI_BTN_START,
		ID_UI_BTN_ATACH_FROM
	};

	bool closed = false;
	HWND hwnd;
	struct table_tab_win win_data;
	AttachWindow& attach_win;

	wxCheckBox* u_touch_win;
	wxTextCtrl* u_file;
	wxTextCtrl* u_file_arg;
	wxCheckBox* u_find_with_name;
	PROCESS_INFORMATION process_info;
	std::vector<HWND> process_hwnds;

	void initUI();
	void initUI_Value(struct table_tab_win& data);

	void onClose(wxCloseEvent &event);
	void onClick(wxCommandEvent&);
	void onSize(wxSizeEvent& evt);
	void onActive(wxActivateEvent&);

	int startProcess(LPPROCESS_INFORMATION lpf);
	void setProcessParent();
	int setWindowParent(LPPROCESS_INFORMATION lpf,int timeout);
	static BOOL enumWindowCallback(HWND hwnd, LPARAM param);
};

#endif /* CODE_SUBWINDOW_H_ */
